//ACCEPTED
#include <cstdio>

int main(){
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        
        int p[4], x, y, t;
        for(int i=1;i<4;i++)p[i]=0;
        
        scanf("%d", &x);
        p[x]=1;
        
        for(int i=0;i<3;i++){
                scanf("%d %d", &x, &y);
                t=p[x];
                p[x]=p[y];
                p[y]=t;
        }
        
        for(int i=1;i<4;i++)if(p[i])printf("%d", i);
        
}